package com.scud.product.controller;

import com.scud.common.result.Result;
import com.scud.model.PageResult;
import com.scud.model.product.dto.AuditPageDto;
import com.scud.model.product.dto.AuditStatusDto;
import com.scud.model.product.pojo.Product;
import com.scud.product.service.AuditService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

/**
 * @author vermouth
 */
@RestController()
@RequestMapping("/api/product/audit")
@Slf4j
public class AuditController {

    @Autowired
    private AuditService auditService;


    /**
     * 获取当前审核人员的商品审核列表
     * @param :
     * @return Result
     * @author vermouth
     */
    @PostMapping("/page")
    public Result getAuditList(@RequestBody AuditPageDto dto){
        log.info("获取当前审核人员的商品审核列表");
        PageResult<Product> result =auditService.getAuditList(dto);
        return Result.success(result);
    }

    /**
     * 审核人员修改审核状态
     * @param dto:
     * @return Result
     * @author vermouth
     */
    @PutMapping("auditStatus")
    @PreAuthorize("hasAuthority('PRODUCT_AUDIT')")
    public Result auditStatus(@RequestBody AuditStatusDto dto){
        log.info("审核人员修改审核状态:{}",dto);
        auditService.auditStatus(dto);
        return Result.success();

    }
}
